﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Xejen.Commands.Models
{
    /// <summary>
    /// 响应参数
    /// </summary>
    public class Response
    {
        /// <summary>
        /// 结果,OK/NG
        /// </summary>
        [JsonProperty("result")]
        [JsonPropertyName("result")]
        public string Result { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        [JsonProperty("message")]
        [JsonPropertyName("message")]
        public string Message { get; set; }
        /// <summary>
        /// 请求时的方法ID，客户MES会原样返回过来
        /// </summary>
        [JsonProperty("method_id")]
        [JsonPropertyName("method_id")]
        public string MethodId { get; set; }
        /// <summary>
        /// 用户会话ID
        /// </summary>
        [JsonProperty("session_id")]
        [JsonPropertyName("session_id")]
        public string SessionId { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuccess
        {
            get
            {
                if (string.IsNullOrEmpty(Result))
                {
                    return false;
                }

                if (Result.ToLower() == "ok")
                {
                    return true;
                }

                return false;
            }
        }

        /// <inheritdoc cref="Response"/>
        public Response() { }
    }
}
